﻿<%template _header%>
<%namespace YouHP.Model%>
<%namespace YouHP.Model.Group%>
<%namespace YouHP.Utility%>
<%namespace YouHP.BLL%>

<script type="text/javascript">
		var curtab = "user";
	    var succ =true;
		function swapTab(tab)
		{

			 var ctrl = _$("ui-" + curtab);
			 ctrl.style.display = 'none';
			 ctrl = _$("ui-" + tab);
			 ctrl.style.display = 'block';
			 curtab = tab;
			
		}
		
        function checkform()
        { 
          var f =_$("postform");
           f.submit();
        }
                  
                
	   
    </script>

<div class="layout-cols2">

		
 <%csharp%>TempUrl = ModuleCtrl.Header4("PatientSearch","搜索病友",false,false); <%/csharp%>
{TempUrl}
<div  style="padding:5px 10px;">
        <div id="search-links" class="searchbox">
	                <img src="/support/Alpha/images/icon_search_results.gif" />
			        <label>搜索条件：</label>
                    <a href="#" id="lnk-location" name="location" onclick="swapTab('location');">地区|</a>
                    <a href="#" id="lnk-age" name="age" onclick="swapTab('age');">年龄|</a> <a href="#"
                        id="lnk-age" name="user" onclick="swapTab('user');">用户名|</a> <a href="#" id="lnk-age"
                            name="disease" onclick="swapTab('disease');">疾病|</a> <a href="#" id="lnk-age" name="treatment"
                                onclick="swapTab('treament');">治疗|</a> <a href="#" id="lnk-age" name="symptom" onclick="swapTab('symptom');">
                                    症状</a>
         </div>

    <div id="search-ui">
        <%csharp%>TempUrl="/User/Group/InvitePatients.aspx";<%/csharp%>
        <form  id="postform" method="get" action="{this.GetUrl(TempUrl)}" >
        <input type="hidden" value="{GroupData.Id}" id="gid"  name="gid"/>
        <table width="700px">
            <tr>
            <td width="10px"></td>
                <td width="400" valign="middle">
                    <div id="ui-location" style="display: none; float:left;">
                     地区: 
                    省份
                    <select name="province" id="province"  onchange="if(this.value !='') setCity(this.options[this.selectedIndex].value)">
                 
                    <option value="">-不限-</option>  

                    <%csharp%>
                    foreach(DistrictInfo Info in ProvinceList)
                    {
                    <%/csharp%>
                    <option value="{Info.Id}">{Info.Name}</option>     
                    <%csharp%>
                    }
                    <%/csharp%>
                    </select>
                    城市
                    <select name="city" id ="city">
                    <option value ="">-不限-</option>
                    </select>
                    </div>
                    <div id="ui-age" style="display: none;float:left;">
                        年龄范围： 
                        <select id="beginyear" name="age1">
                            <option value="-1" selected>不限</option>
                            <option value="10">10</option>
                            <option value="20">20</option>
                            <option value="20">30</option>
                            <option value="20">40</option>
                            <option value="20">50</option>
                            <option value="20">60</option>
                            <option value="20">70</option>
                        </select>岁 到
                        <select id="endyear" name="age2">
                            <option value="-1" selected>不限</option>
                            <option value="10">10</option>
                            <option value="20">20</option>
                            <option value="20">30</option>
                            <option value="20">40</option>
                            <option value="20">50</option>
                            <option value="20">60</option>
                            <option value="20">70</option>
                            <option value="20">80</option>
                        </select>岁

                    </div>
                    <div id="ui-user" style="display: block;float:left;">
                        用户名：
                        <input type="text" id="username" name="name" length="20">
                    </div>
                    <div id="ui-disease" style="display: none;float:left;">
                        疾病:
                        <select id="disease" name="dszid">
                            <option value="" selected>不限</option>
                            <%csharp%>
                            foreach( DiseaseInfo Info in DiseaseLst) {
                            <%/csharp%>
                            <option value="{Info.Id}">{Info.Name}</option>
                            <%csharp%>
                            }
                            <%/csharp%>
                        </select>
                    </div>
                    <div id="ui-treament" style="display: none;float:left;">
                        治疗：
                        <select id="treatmentname" name="trmname">
                            <option value="" selected>不限</option>
                            <%csharp%>
                            foreach( TreatmentInfo Info in TreatmentLst) {
                            <%/csharp%>
                            <option value="{Info.Id}">{Info.Name}</option>
                            <%csharp%>
                            }
                            <%/csharp%>
                        </select>
                    </div>
                    <div id="ui-symptom" style="display: none;float:left;">
                        症状：
                        <select id="symptomname" name="symname">
                            <option value="" selected>不限</option>
                            <%csharp%>
                            foreach( SymptomInfo Info in SymptomLst) {
                            <%/csharp%>
                            <option value="{Info.Id}">{Info.Name}</option>
                            <%csharp%>
                            }
                            <%/csharp%>
                        </select>
                    </div> 
                           &nbsp;&nbsp; <input id="post" type="button" value="寻找病友" onclick="checkform()" class="button"/>
                </td>
                    
                
            </tr>
        </table> 
      
        </form>
        
    </div>  
 </div>
 <%csharp%>TempUrl = ModuleCtrl.Footer("PatientSearch"); <%/csharp%>
 {TempUrl}
 
 
 
 <%csharp%>TempUrl = ModuleCtrl.Header4("PatientList","病友列表",false,false); <%/csharp%>
{TempUrl}
			<%csharp%> if(PatientDataList.Count == 0){ <%/csharp%>
               <div class="content">
				<p><b>找不到相应的病人!!</b></p>
				</div>
				<%csharp%> } else { <%/csharp%>
	<table  border="0" cellpadding="0" cellspacing="0" class="plist1">
	      <tr align="center" style="height:30px;"> 
            <td width="10%" height="26" align="center"><b class="tdtitle">头像</b></td>

            <td width="20%"><b class="tdtitle">疾病</b></td>
            <td width="20%"><b class="tdtitle">性别/年龄/地区</b></td>
             <td width="30%"><b class="tdtitle"> 个人简介</b></td>
            <td>&nbsp;</td>
           
            </tr>
				<%csharp%>
				string str="tr_bgcolor_0";
				foreach(UserInfo item in PatientDataList) { 
				
				<%/csharp%>
					<tbody><tr height="60" class="{str}">
					<%csharp%>TempUrl = "/Profile/Index.aspx?uid=" + item.Id; <%/csharp%>
						<td  align="center" style="padding:5px;">
						    <a href="{this.GetUrl(TempUrl)}" class="user_img"><img src="{item.Avatar}" height="48" width="48"></img><br />
						    {item.UserName}</a></td>
						
						<td  align="center">
							<%csharp%>TempUrl = "/Disease.aspx?id=" + item.DiseaseId; <%/csharp%>
							<a href="{this.GetUrl(TempUrl)}">{item.DiseaseName}</a>
							<p><font color="#808080">
							(<%csharp%>if(item.EnduringYear >= 1) { <%/csharp%> {item.EnduringYear}年 <%csharp%> } else { <%/csharp%>不到一年
							<%csharp%> } <%/csharp%>)</font></p>
						</td>
						<td  align="center" valign="middle">
						  {item.Gender}/<%if item.Age>0&&item.Age<208%>{item.Age}<%else%>未知<%/if%>/

						    <%if item.Province!=""||item.City!=""%>{item.Province}&nbsp;{item.City}<%else%>未知<%/if%>
						  </td>  
						  
						  <%csharp%>
						string sb=item.Description; 
						if(sb.Length==0){sb="暂无个人简介";}
						if(sb.Length>50){
						sb=sb.Substring(0,Math.Min(50,sb.Length))+"……";}
						<%/csharp%>
						
						<td valign="middle" style="padding-left:15px;"><span style="text-overflow:ellipsis; margin:5px;">{sb}</span></td>
						  
						<%csharp%>
						int role = GroupUserBLL.Instance.GetGroupUserInfo(GroupData.Id,item.Id).Role;
						if(role == Constants.RoleAdmin || role == Constants.RoleCreator || role == Constants.RoleMember || role == Constants.RoleBlacklist || role == Constants.RoleInviting)
						{
						<%/csharp%>
						<td align="center"><font style="font-weight:bold;">已邀请</font></td>
						<%csharp%>}else{<%/csharp%>
						<td align=center id="invite{item.Id}"><a href="javascript:SendInvitation({GroupData.Id},{item.Id});" class="yellowbutton" id="sendbutton{item.Id}">发送邀请</a></td>
                        <%csharp%>}<%/csharp%>

					</tr></tbody>
					<%csharp%>
					if(str=="tr_bgcolor_0") str="tr_bgcolor_1";
					else str="tr_bgcolor_0";
					
					
					}<%/csharp%>
				</table>				
				<%csharp%> } <%/csharp%>
 <%csharp%>TempUrl = ModuleCtrl.Footer("PatientList"); <%/csharp%>
 {TempUrl}
	
		<div class="box">
			<div class="content">
				<div class="pages">
					{PatientPagingString}
				</div>
			</div>
		</div>
<script type="text/javascript">
function SendInvitation(gid,uid)
{
   
   var aurl = "/Pages/alpha/User/Group/InvitePatientsAjax.aspx?gid="+gid+"&toUserId="+uid;

  _$("sendbutton"+uid).innerText="正在处理...";
  var myAjax=new Ajax(aurl,
  {
     method:'get',
     onComplete:function()
     {
      var flag=this.response.text;
      switch(flag)
      {
        case"0":
        _$("invite"+uid).innerHTML="<font style=\"font-weight:bold;\">发送成功！</font>";
        break;
        case"1":
        alert("该用户已经是圈子成员！");
        _$("sendbutton"+uid).innerText="已是成员";
        break;
        case"2":
        alert("已向该用户发送过邀请，不能重复发送！");
        _$("sendbutton"+uid).innerText="已邀请";
        break;
        case"3":
        alert("发送失败！");
        break;
      }

     }
   }
   );
   myAjax.request();


}

</script>
	
</div>

<%template _footer%>		
